﻿Public Partial Class Wfrm_Paso2
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'If Session("especialidad") Is Nothing And Session("medico") Is Nothing Then
        Response.Redirect("../default.aspx")
        'End If

        If Not Page.IsPostBack Then
            Carg_Carga_Grilla()
        End If

    End Sub

    Sub Carg_Carga_Grilla()

        Dim exec As New DotNetDal.SQLPersistence(False, "cnn", DotNetDal.SQLPersistence.Provider.SQLCLIENT)
        Dim rp As New DotNetResponse.SQLPersistence

        If Session("especialidad") = "" Then
            rp.StoredProcedure = "SP_AME_Get_Med_Med"
            rp.AddParametro(Session("medico"))
        Else
            rp.StoredProcedure = "SP_AME_Get_Med_Esp"
            rp.AddParametro(Session("especialidad"))
        End If

        exec.ExecuteDataTable(rp)

        If rp.TieneDatos Then
            grcargamed.DataSource = rp.DtTable
            grcargamed.DataBind()
            grcargamed.UpdateAfterCallBack = True
        End If

        If rp.Errores Then
            MsgBox("Error")
        End If

        rp.Dispose()
    End Sub


    Protected Sub grcargamed_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles grcargamed.SelectedIndexChanged
        Session("especialidad_codigo") = grcargamed.SelectedItem.Cells(5).Text
        Session("pdt_rut") = grcargamed.SelectedItem.Cells(6).Text
        Session("prox_hora") = grcargamed.SelectedItem.Cells(3).Text
        Session("centro_medico") = grcargamed.SelectedItem.Cells(2).Text
        Session("profesional") = grcargamed.SelectedItem.Cells(0).Text
        Session("especialidad_texto") = grcargamed.SelectedItem.Cells(1).Text
        Response.Redirect("Wfrm_Paso3.aspx", True)
    End Sub

    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox1.TextChanged

    End Sub
End Class